/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-16
 * Time: 9:38
 */
public class Test {

    //字符串相乘
    public String multiply(String num1, String num2) {
        //将字符串逆置后转换为字符数组
        int len1 = num1.length(), len2 = num2.length();
        char[] n1 = new StringBuilder(num1).reverse().toString().toCharArray();
        char[] n2 = new StringBuilder(num2).reverse().toString().toCharArray();
        int[] ret = new int[len1 + len2 - 1];

        for (int i = 0; i < len1; i++) {
            for (int j = 0; j < len2; j++) {
                ret[i + j] += (n1[i] - '0') * (n2[j] - '0');
            }
        }

        int t = 0, cur = 0;
        StringBuilder sb = new StringBuilder();
        while (cur < len1 + len2 - 1 || t != 0) {
            if (cur < len1 + len2 - 1) t += ret[cur++];
            sb.append((char)(t % 10 + '0'));
            t /= 10;
        }

        while (sb.length() > 1 && sb.charAt(sb.length() - 1) == '0') {
            sb.deleteCharAt(sb.length() - 1);
        }

        return sb.reverse().toString();
    }
    public static void main(String[] args) {
        String str = "fsjfhjkd";
        StringBuilder sb = new StringBuilder("ahskjfa");
        StringBuffer sb1 = new StringBuffer("fjkdfjds");
        sb1.deleteCharAt(0);
        int[] arr = {1,2,3,4};
        StringBuilder sb2 = new StringBuilder(arr.toString()).reverse();
    }
}
